package com.yiyuan.app.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.guaike.core.mybatis.plugins.BaseDAO;
import com.yiyuan.app.entity.po.DDetailsPineconePO;
import com.yiyuan.app.mapper.DDetailsPineconeMapper;
import org.springframework.stereotype.Repository;

@Repository
public class DDetailsPineconeDAO extends BaseDAO<DDetailsPineconeMapper, DDetailsPineconePO> {


    public Page<DDetailsPineconePO> findPageByLabelType(Long userId, Integer labelType, Integer pageIndex, Integer pageSize) {
        LambdaQueryWrapper<DDetailsPineconePO> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(DDetailsPineconePO::getUserId, userId);
        queryWrapper.eq(DDetailsPineconePO::getLabelType, labelType);
        queryWrapper.orderByDesc(DDetailsPineconePO::getId);
        return getBaseMapper().selectPage(new Page<>(pageIndex, pageSize), queryWrapper);
    }

    public Page<DDetailsPineconePO> findPage(Long userId, Integer pageIndex, Integer pageSize) {
        LambdaQueryWrapper<DDetailsPineconePO> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(DDetailsPineconePO::getUserId, userId);
        queryWrapper.orderByDesc(DDetailsPineconePO::getId);
        return getBaseMapper().selectPage(new Page<>(pageIndex, pageSize), queryWrapper);
    }
}
